namespace UniversalAdmin.Application.Dtos;

public class PageRequestDto
{
    private int _pageIndex = 1;
    private int _pageSize = 10;

    private readonly int MinPageSize = 10; // 最小的页条目数
    private readonly int MaxPageSize = 100; // 最大的页条目数

    public int PageIndex
    {
        get => _pageIndex;
        set => _pageIndex = value < 1 ? 1 : value;// 当前页码小于1时，自动设置为1，否则为设置的值
    }

    public int PageSize
    {
        get => _pageSize;
        set => _pageSize = value < 1 ? MinPageSize : (value > MaxPageSize ? MaxPageSize : value);// 页条目数小于1，自动设置10；页条目数大于100，自动限制为100
    }

    /// <summary>
    /// 搜索关键字
    /// </summary>
    public string? SearchKeyword { get; set; }

    /// <summary>
    /// 排序字段
    /// </summary>
    public string? SortField { get; set; }

    /// <summary>
    /// 排序方向（asc/desc）
    /// </summary>
    public string? SortDirection { get; set; } = "asc";
}